package com.headwind.logistics.logistics.service.impl;

import com.headwind.logistics.logistics.mapper.LogisticsCustomerWorkOrderMapper;
import com.headwind.logistics.logistics.pojo.LogisticsWorkOrder;
import com.headwind.logistics.logistics.pojo.LogisticsWorkOrderContent;
import com.headwind.logistics.logistics.service.intl.LogisticsWorkOrderServiceIntl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 小恶魔
 * @Date 2020-08-01 9:39
 * @Version 1.0
 * @DESCRIPTION 顾客工单业务逻辑层
 */
@Service
public class LogisticsWorkOrderServiceImpl implements LogisticsWorkOrderServiceIntl {

    //顾客工单数据访问层
    @Resource
    private LogisticsCustomerWorkOrderMapper logisticsCustomerWorkOrderMapper;

    /**
     * 根据顾客id获取工单信息
     * @param customerId
     * @param page
     * @param rows
     * @return
     */
    @Override
    public List<LogisticsWorkOrder> queryWorkOrderByCustomerId(String startDate,String endDate,Long customerId, Integer page, Integer rows) {

        if (null != page){
            page = (page-1)*rows;
        }

        List<LogisticsWorkOrder> logisticsWorkOrders =
                logisticsCustomerWorkOrderMapper.queryWorkOrderByCustomerId(startDate,endDate,customerId, page, rows);

        return logisticsWorkOrders;
    }

    /**
     * 添加工单内容表
     * @param logisticsWorkOrderContent
     * @return
     */
    @Override
    public Integer addWorkOrderContent(LogisticsWorkOrderContent logisticsWorkOrderContent) {

        logisticsWorkOrderContent.setReplyContent("");

        return logisticsCustomerWorkOrderMapper.addWorkOrderContent(logisticsWorkOrderContent);
    }

    /**
     * 修改工单状态
     * @param workOrder
     * @return
     */
    @Override
    public Integer updateWorkOrder(LogisticsWorkOrder workOrder) {

        return logisticsCustomerWorkOrderMapper.updateWorkOrder(workOrder);
    }
}
